<?php
namespace froyo\cherry\web;
use froyo\cherry\Base\BaseRoute;
use froyo\cherry\Base\Cherry;


class Route extends BaseRoute{

	public function paraseRequest($request){
		$routes = [
			'module'=>$this->defaultModule,
			'controller'=>$this->defaultController,
			'action'=>$this->defaultAction
		];
		$routeparam = $request->get(Cherry::$app->getParam('routeparam'));
		if(!$routeparam)
		{
			//解析pathinfo
			$routeparam = $request->getPathinfo();
		}
		if($routeparam)
		{
			$routedata = explode('/', $routeparam);
			if(isset($routedata[0]))
			{
				$routes['module'] = $routedata[0];
			}
			if(isset($routedata[1]))
			{
				$routes['controller'] = $routedata[1];
			}
			if(isset($routedata[2]))
			{
				$routes['action'] = $routedata[2];
			}
		}
		return $routes;
	}
}